//
//  CXHToBidConfigAdapter.m
//  CXHAdSDK-ToBid
//
//  Created by 陈坤 on 2025/4/4.
//

#import "CXHToBidConfigAdapter.h"
#import <CXHAdSDK-Core/CXHAdSDK.h>

@interface CXHToBidConfigAdapter ()

@property (nonatomic, weak) id<AWMCustomConfigAdapterBridge> bridge;

@end

@implementation CXHToBidConfigAdapter


- (instancetype)initWithBridge:(id<AWMCustomConfigAdapterBridge>)bridge {
    self = [super init];
    if (self) {
        _bridge = bridge;
    }
    return self;
}
- (AWMCustomAdapterVersion *)basedOnCustomAdapterVersion {
    return AWMCustomAdapterVersion1_0;
}
- (NSString *)adapterVersion {
    return @"1.0.0";
}
- (NSString *)networkSdkVersion {
    return [CXHAdSDK getSDKVersion];
}
- (void)initializeAdapterWithConfiguration:(AWMSdkInitConfig *)initConfig {
    NSString *appId = [initConfig.extra objectForKey:@"appid"];
    NSString *domain = [initConfig.extra objectForKey:@"domain"];
    [CXHAdSDK initWithAppId:appId requestDomain:domain completionBlock:^(NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (!error) {
                [self.bridge initializeAdapterSuccess:self];
            }else {
                [self.bridge initializeAdapterFailed:self error:error];
            }
        });
    }];
}
- (void)didRequestAdPrivacyConfigUpdate:(NSDictionary *)config {
//    WindMillPersonalizedAdvertisingState personalizedAdvertisingState = [WindMillAds getPersonalizedAdvertisingState];
//    if (personalizedAdvertisingState == WindMillPersonalizedAdvertisingOn) {
//        [BUAdSDKManager setUserExtData:@"[{\"name\":\"personal_ads_type\",\"value\":\"1\"}]"];
//    }else if (personalizedAdvertisingState == WindMillPersonalizedAdvertisingOff) {
//        [BUAdSDKManager setUserExtData:@"[{\"name\":\"personal_ads_type\",\"value\":\"0\"}]"];
//    }
}

@end
